package team.tunan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import team.tunan.common.Result;
import team.tunan.entity.dto.MatchInfo;
import team.tunan.service.IMatchesService;

/**
 * @Date 2022/7/10
 * @Author ztc
 * @Description TODO
 */

@Controller
@RequestMapping("/show")
public class ShowController {


    @Autowired
    private IMatchesService matchService;

    @RequestMapping("/verify")
    @ResponseBody
    public Result verify(){
        if (matchService.getMatchVerify()){
            return new Result("跳转中...",null,true);
        }
        return new Result("当前没有对战进行",null,false);

    }

    @RequestMapping("/doShow/{mid}")
    public ModelAndView show(@PathVariable Integer mid, Model model){
        MatchInfo matchToShow = matchService.getMatchToShow(mid);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("info",matchToShow);
        modelAndView.setViewName("show");
        return modelAndView;

    }

    @RequestMapping("/showList")
    public String score(Model model){
//        MatchInfo matchToShow = matchService.getMatchToShow();
//        model.addAttribute("info",matchToShow);
        return "showList";
    }

}
